/** 
 * \file ctrl_station.c
 * \brief Controle les station enregistée
 * \author Nicolas.M
 * \version 0.7
 * \date 10 mars 2011
 *
 */

#include "ctrl_station.h"

#include "../driver/frequence.h"


char *stationsName[] =
		{
		"Fun Radio",
		"NRJ",
		"RTL",
		"RadOrient",
		"RFM",
		"USER 1",
		"USER 2",
		"USER 3",
		"USER 4",
		"USER 5"
		};
// 		{
// 		"Lyon 1ere",
// 		"Sccop",
// 		"BFM",
// 		"Classiq",
// 		"JAZZ",
// 		"Hit&Sport",
// 		"Capsao",
// 		"Virgin",
// 		"NRJ",
// 		"RMC INFO",
// 		"RTL",
// 		"IMPACT",
// 		"RFM",
// 		"USER 1",
// 		"USER 2",
// 		"USER 3",
// 		"USER 4",
// 		"USER 5",
// 		};

int stationsFreq[NB_STATIONS] =
		{
		257,
		596,
		698,
		783,
		815
		};
// 		{
// 		218,
// 		256,
// 		340,
// 		374,
// 		401,
// 		442,
// 		465,
// 		504,
// 		611,
// 		665,
// 		709,
// 		770,
// 		825
// 		};

int stationCourante = 0;

void stationSuivante()
{
	stationCourante = stationCourante < NB_STATIONS-1 ? stationCourante+1 : 0;
	setFrequence(stationsFreq[stationCourante]);
}

void stationPrecedente()
{
	stationCourante = stationCourante > 0 ? stationCourante-1 : NB_STATIONS-1;
	setFrequence(stationsFreq[stationCourante]);
}

void restaurerStation(int station)
{
	stationCourante = (station >= 0 && station < NB_STATIONS) ? station : 0;
	setFrequence(stationsFreq[stationCourante]);
}


void restaurerUserStation(int station, int val)
{
	stationsFreq[NB_STATIONS-6+station] = val;
}
void restaurerUserStations(unsigned int *userStations)
{
	int i = 0, userIdx = NB_STATIONS-5;
	while (i<5)
	{
		stationsFreq[userIdx++] = userStations[i++];
	}
}

int getStationCourante()
{
	return stationCourante;
}

char *getStationCouranteName()
{
	return stationsName[stationCourante];
}

char ** getListeStations()
{
	return stationsName;
}


